
public class TriangularMembershipFunction extends MembershipFunction {

	public TriangularMembershipFunction(double mean, double width) {
		lowerBound = mean - width;
		sampledValues = new double[(int)(width * 2 / RESOLUTION) + 1];
		for (int i = 0; i < sampledValues.length; i++) {
			double x = lowerBound + i * RESOLUTION;
			sampledValues[i] = Math.max(Math.min((x - lowerBound) / width, ((mean + width) - x) / width), 0);
		}
	}

}
